		TITLE	ADDTOEXT - Copyright (C) 1994 SLR Systems

		INCLUDE	MACROS
		INCLUDE	SYMBOLS
		INCLUDE	LIBRARY

		PUBLIC	ADD_TO_EXTERNAL_LIST,ADD_TO_WEAK_LIST,REMOVE_FROM_WEAK_LIST,REMOVE_FROM_EXTERNAL_LIST
		PUBLIC	REMOVE_FROM_LIBSYM_LIST,REMOVE_FROM_VIRDEF_LIST,ADD_TO_ALIASED_LIST,REMOVE_FROM_ALIASED_LIST
		PUBLIC	REMOVE_FROM_COMMUNAL_LIST,ADD_TO_COMDAT_LIST,ADD_TO_WEAK_DEFINED_LIST,REMOVE_FROM_WEAK_DEFINED_LIST
		PUBLIC	ADD_TO_COMMUNAL_LIST,ADD_TO_LAZY_LIST,ADD_TO_LAZY_DEFINED_LIST,ADD_TO_ALIAS_DEFINED_LIST
		PUBLIC	REMOVE_FROM_ALIAS_DEFINED_LIST,REMOVE_FROM_LAZY_LIST,REMOVE_FROM_LAZY_DEFINED_LIST,REMOVE_FROM_COMDAT_LIST
		PUBLIC	ADD_TO_COMDAT_ORDERED_LIST,ADD_TO__IMP__LIST,REMOVE_FROM__IMP__LIST,REMOVE_FROM_UNDECORATED_LIST


		.DATA

		EXTERNDEF	FIRST_EXTERNAL_GINDEX:DWORD,LAST_EXTERNAL_GINDEX:DWORD,CURNMOD_GINDEX:DWORD,FIRST_WEAK_GINDEX:DWORD
		EXTERNDEF	LAST_WEAK_GINDEX:DWORD,FIRST_VIRDEF_GINDEX:DWORD,LAST_VIRDEF_GINDEX:DWORD,FIRST_ALIASED_GINDEX:DWORD
		EXTERNDEF	LAST_ALIASED_GINDEX:DWORD,FIRST_COMMUNAL_GINDEX:DWORD,LAST_COMMUNAL_GINDEX:DWORD
		EXTERNDEF	FIRST_COMDAT_GINDEX:DWORD,LAST_COMDAT_GINDEX:DWORD,FIRST_WEAK_DEFINED_GINDEX:DWORD
		EXTERNDEF	FIRST_LAZY_GINDEX:DWORD,LAST_WEAK_DEFINED_GINDEX:DWORD,LAST_LAZY_GINDEX:DWORD
		EXTERNDEF	FIRST_LAZY_DEFINED_GINDEX:DWORD,LAST_LAZY_DEFINED_GINDEX:DWORD,FIRST_ALIAS_DEFINED_GINDEX:DWORD
		EXTERNDEF	LAST_ALIAS_DEFINED_GINDEX:DWORD,FIRST_COMDAT_ORDERED_GINDEX:DWORD,LAST_COMDAT_ORDERED_GINDEX:DWORD
		EXTERNDEF	FIRST__IMP__GINDEX:DWORD,LAST__IMP__GINDEX:DWORD,FIRST_UNDECORATED_GINDEX:DWORD
		EXTERNDEF	LAST_UNDECORATED_GINDEX:DWORD

		EXTERNDEF	LIBRARY_GARRAY:STD_PTR_S,SYMBOL_GARRAY:STD_PTR_S


		.CODE	PASS1_TEXT

		public _add_to_undecorated_list
_add_to_undecorated_list	PROC
		mov	ECX,8[ESP]
		mov	EAX,4[ESP]
_add_to_undecorated_list	endp

ADD_TO_UNDECORATED_LIST	PROC
		;
		;EAX IS GINDEX, ECX IS PHYS
		;RETURNS SAME
		;
		ASSUME	ECX:PTR SYMBOL_STRUCT

		PUSH	EBX
		MOV	EDX,LAST_UNDECORATED_GINDEX

		MOV	LAST_UNDECORATED_GINDEX,EAX
		MOV	[ECX]._S_PREV_SYM_GINDEX,EDX

		MOV	BL,NSYM_UNDECORATED
		TEST	EDX,EDX

		MOV	[ECX]._S_NSYM_TYPE,BL
		JNZ	ATE_FINAL

		MOV	FIRST_UNDECORATED_GINDEX,EAX
		JMP	AF_RET

ADD_TO_UNDECORATED_LIST	ENDP


		public _add_to__imp__list
_add_to__imp__list	PROC
		mov	ECX,8[ESP]
		mov	EAX,4[ESP]
_add_to__imp__list	endp

ADD_TO__IMP__LIST	PROC
		;
		;EAX IS GINDEX, ECX IS PHYS
		;RETURNS SAME
		;
		ASSUME	ECX:PTR SYMBOL_STRUCT

		PUSH	EBX
		MOV	EDX,LAST__IMP__GINDEX

		MOV	LAST__IMP__GINDEX,EAX
		MOV	[ECX]._S_PREV_SYM_GINDEX,EDX

		MOV	BL,NSYM__IMP__
		TEST	EDX,EDX

		MOV	[ECX]._S_NSYM_TYPE,BL
		JNZ	ATE_FINAL

		MOV	FIRST__IMP__GINDEX,EAX
		JMP	AF_RET

ADD_TO__IMP__LIST	ENDP


		public _add_to_aliased_list
_add_to_aliased_list	PROC
		mov	ECX,8[ESP]
		mov	EAX,4[ESP]
_add_to_aliased_list	endp

ADD_TO_ALIASED_LIST	PROC
		;
		;EAX IS GINDEX, ECX IS PHYS
		;RETURNS SAME
		;
		ASSUME	ECX:PTR SYMBOL_STRUCT

		PUSH	EBX
		MOV	EDX,LAST_ALIASED_GINDEX
		MOV	LAST_ALIASED_GINDEX,EAX
		MOV	[ECX]._S_PREV_SYM_GINDEX,EDX
		MOV	BL,NSYM_ALIASED
		TEST	EDX,EDX
		MOV	[ECX]._S_NSYM_TYPE,BL
		JNZ	ATE_FINAL
		MOV	FIRST_ALIASED_GINDEX,EAX
		JMP	AF_RET

ADD_TO_ALIASED_LIST	ENDP


		public _add_to_external_list
_add_to_external_list	PROC
		mov	ECX,8[ESP]
		mov	EAX,4[ESP]
_add_to_external_list	endp

ADD_TO_EXTERNAL_LIST	PROC
		;
		;EAX IS GINDEX, ECX IS PHYSICAL
		;
		;RETURNS SAME
		;
		PUSH	EBX
		MOV	EDX,LAST_EXTERNAL_GINDEX
		MOV	LAST_EXTERNAL_GINDEX,EAX
		MOV	[ECX]._S_PREV_SYM_GINDEX,EDX
		MOV	BL,NSYM_EXTERNAL
		TEST	EDX,EDX
		MOV	[ECX]._S_NSYM_TYPE,BL
		JZ	ADD_FIRST
ATE_FINAL::
		CONVERT	EDX,EDX,SYMBOL_GARRAY
		ASSUME	EDX:PTR SYMBOL_STRUCT


		XOR	EBX,EBX			;NO NEXT SYMBOL
		MOV	[EDX]._S_NEXT_SYM_GINDEX,EAX
		MOV	EDX,CURNMOD_GINDEX
		MOV	[ECX]._S_NEXT_SYM_GINDEX,EBX
		POP	EBX
		MOV	[ECX]._S_REF_MOD_GINDEX,EDX
		RET

ADD_FIRST:
		MOV	FIRST_EXTERNAL_GINDEX,EAX
AF_RET::
		XOR	EBX,EBX			;NO NEXT SYMBOL
		MOV	EDX,CURNMOD_GINDEX
		MOV	[ECX]._S_NEXT_SYM_GINDEX,EBX
		POP	EBX
		MOV	[ECX]._S_REF_MOD_GINDEX,EDX
		RET


ADD_TO_EXTERNAL_LIST	ENDP


		public _add_to_weak_list
_add_to_weak_list	PROC
		mov	ECX,8[ESP]
		mov	EAX,4[ESP]
_add_to_weak_list	endp

ADD_TO_WEAK_LIST	PROC
		;
		;EAX IS GINDEX, ECX IS PHYS
		;RETURNS SAME
		;
		PUSH	EBX
		MOV	EDX,LAST_WEAK_GINDEX
		MOV	LAST_WEAK_GINDEX,EAX
		MOV	[ECX]._S_PREV_SYM_GINDEX,EDX
		MOV	BL,NSYM_WEAK_EXTRN
		TEST	EDX,EDX
		MOV	[ECX]._S_NSYM_TYPE,BL
		JNZ	ATE_FINAL
		MOV	FIRST_WEAK_GINDEX,EAX
		JMP	AF_RET

ADD_TO_WEAK_LIST	ENDP


		public _add_to_lazy_list
_add_to_lazy_list	PROC
		mov	ECX,8[ESP]
		mov	EAX,4[ESP]
_add_to_lazy_list	endp

ADD_TO_LAZY_LIST	PROC
		;
		;EAX IS GINDEX, ECX IS PHYS
		;RETURNS SAME
		;
		PUSH	EBX
		MOV	EDX,LAST_LAZY_GINDEX
		MOV	LAST_LAZY_GINDEX,EAX
		MOV	[ECX]._S_PREV_SYM_GINDEX,EDX
		MOV	BL,NSYM_LAZY
		TEST	EDX,EDX
		MOV	[ECX]._S_NSYM_TYPE,BL
		JNZ	ATE_FINAL
		MOV	FIRST_LAZY_GINDEX,EAX
		JMP	AF_RET

ADD_TO_LAZY_LIST	ENDP



		public _add_to_comdat_ordered_list
_add_to_comdat_ordered_list	PROC
		mov	ECX,8[ESP]
		mov	EAX,4[ESP]
_add_to_comdat_ordered_list	endp

ADD_TO_COMDAT_ORDERED_LIST	PROC
		;
		;EAX IS GINDEX, ECX IS PHYS
		;RETURNS SAME
		;
		PUSH	EBX
		MOV	EDX,LAST_COMDAT_ORDERED_GINDEX
		MOV	LAST_COMDAT_ORDERED_GINDEX,EAX
		MOV	[ECX]._S_PREV_SYM_GINDEX,EDX
		MOV	BL,NSYM_COMDAT
		TEST	EDX,EDX
		MOV	[ECX]._S_NSYM_TYPE,BL
		JNZ	ATC_FINAL
		MOV	FIRST_COMDAT_ORDERED_GINDEX,EAX
		JMP	AC_RET

ADD_TO_COMDAT_ORDERED_LIST	ENDP


		public _add_to_alias_defined_list
_add_to_alias_defined_list	PROC
		mov	ECX,8[ESP]
		mov	EAX,4[ESP]
_add_to_alias_defined_list	endp

ADD_TO_ALIAS_DEFINED_LIST	PROC
		;
		;EAX IS GINDEX, ECX IS PHYS
		;RETURNS SAME
		;
		PUSH	EBX
		MOV	EDX,LAST_ALIAS_DEFINED_GINDEX
		MOV	LAST_ALIAS_DEFINED_GINDEX,EAX
		MOV	[ECX]._S_PREV_SYM_GINDEX,EDX
		MOV	BL,NSYM_ALIAS_DEFINED
		TEST	EDX,EDX
		MOV	[ECX]._S_NSYM_TYPE,BL
		JNZ	ATC_FINAL
		MOV	FIRST_ALIAS_DEFINED_GINDEX,EAX
		JMP	AC_RET

ADD_TO_ALIAS_DEFINED_LIST	ENDP


		public _add_to_comdat_list
_add_to_comdat_list	PROC
		mov	ECX,8[ESP]
		mov	EAX,4[ESP]
_add_to_comdat_list	endp

ADD_TO_COMDAT_LIST	PROC
		;
		;EAX IS GINDEX, ECX IS PHYS
		;RETURNS SAME
		;
		PUSH	EBX
		MOV	EDX,LAST_COMDAT_GINDEX
		MOV	LAST_COMDAT_GINDEX,EAX
		MOV	[ECX]._S_PREV_SYM_GINDEX,EDX
		MOV	BL,NSYM_COMDAT
		TEST	EDX,EDX
		MOV	[ECX]._S_NSYM_TYPE,BL
		JZ	ADD_FIRST
ATC_FINAL::
		CONVERT	EDX,EDX,SYMBOL_GARRAY
		XOR	EBX,EBX
		MOV	[EDX]._S_NEXT_SYM_GINDEX,EAX
		MOV	[ECX]._S_NEXT_SYM_GINDEX,EBX
		POP	EBX
		RET

ADD_FIRST:
		MOV	FIRST_COMDAT_GINDEX,EAX
AC_RET::
		XOR	EDX,EDX
		POP	EBX
		MOV	[ECX]._S_NEXT_SYM_GINDEX,EDX
		RET


ADD_TO_COMDAT_LIST	ENDP


		public _add_to_weak_defined_list
_add_to_weak_defined_list	PROC
		mov	ECX,8[ESP]
		mov	EAX,4[ESP]
_add_to_weak_defined_list	endp

ADD_TO_WEAK_DEFINED_LIST	PROC
		;
		;EAX IS GINDEX, ECX IS PHYS
		;RETURNS SAME
		;
		PUSH	EBX
		MOV	EDX,LAST_WEAK_DEFINED_GINDEX
		MOV	LAST_WEAK_DEFINED_GINDEX,EAX
		MOV	[ECX]._S_PREV_SYM_GINDEX,EDX
		MOV	BL,NSYM_WEAK_DEFINED
		TEST	EDX,EDX
		MOV	[ECX]._S_NSYM_TYPE,BL
		JNZ	ATC_FINAL
		MOV	FIRST_WEAK_DEFINED_GINDEX,EAX
		JMP	AC_RET

ADD_TO_WEAK_DEFINED_LIST	ENDP


		public _add_to_lazy_defined_list
_add_to_lazy_defined_list	PROC
		mov	ECX,8[ESP]
		mov	EAX,4[ESP]
_add_to_lazy_defined_list	endp

ADD_TO_LAZY_DEFINED_LIST	PROC
		;
		;EAX IS GINDEX, ECX IS PHYS
		;RETURNS SAME
		;
		PUSH	EBX
		MOV	EDX,LAST_LAZY_DEFINED_GINDEX
		MOV	LAST_LAZY_DEFINED_GINDEX,EAX
		MOV	[ECX]._S_PREV_SYM_GINDEX,EDX
		MOV	BL,NSYM_LAZY_DEFINED
		TEST	EDX,EDX
		MOV	[ECX]._S_NSYM_TYPE,BL
		JNZ	ATC_FINAL
		MOV	FIRST_LAZY_DEFINED_GINDEX,EAX
		JMP	AC_RET

ADD_TO_LAZY_DEFINED_LIST	ENDP


		public _add_to_communal_list
_add_to_communal_list	PROC
		mov	ECX,8[ESP]
		mov	EAX,4[ESP]
_add_to_communal_list	endp

ADD_TO_COMMUNAL_LIST	PROC
		;
		;EAX IS GINDEX, ECX IS PHYS
		;RETURNS SAME
		;
		PUSH	EBX
		MOV	EDX,LAST_COMMUNAL_GINDEX
		MOV	LAST_COMMUNAL_GINDEX,EAX
		MOV	[ECX]._S_PREV_SYM_GINDEX,EDX
		TEST	EDX,EDX
		JNZ	ATC_FINAL
		MOV	FIRST_COMMUNAL_GINDEX,EAX
		JMP	AC_RET

ADD_TO_COMMUNAL_LIST	ENDP


		ASSUME	EDX:NOTHING,ECX:NOTHING


REMOVE_FROM_VIRDEF_LIST	PROC

		PUSH	EDI
		MOV	EDI,OFF FIRST_VIRDEF_GINDEX
		JMP	RFEL_1

REMOVE_FROM_VIRDEF_LIST	ENDP


		public _remove_from_communal_list
_remove_from_communal_list	PROC
		mov	ECX,8[ESP]
		mov	EAX,4[ESP]
_remove_from_communal_list	ENDP

REMOVE_FROM_COMMUNAL_LIST	PROC

		PUSH	EDI
		MOV	EDI,OFF FIRST_COMMUNAL_GINDEX
		JMP	RFEL_1

REMOVE_FROM_COMMUNAL_LIST	ENDP


REMOVE_FROM_ALIAS_DEFINED_LIST	PROC

		PUSH	EDI
		MOV	EDI,OFF FIRST_ALIAS_DEFINED_GINDEX
		JMP	RFEL_1

REMOVE_FROM_ALIAS_DEFINED_LIST	ENDP


		public _remove_from_lazy_list
_remove_from_lazy_list	PROC
		mov	ECX,8[ESP]
		mov	EAX,4[ESP]
_remove_from_lazy_list	ENDP

REMOVE_FROM_LAZY_LIST	PROC

		PUSH	EDI
		MOV	EDI,OFF FIRST_LAZY_GINDEX
		JMP	RFEL_1

REMOVE_FROM_LAZY_LIST	ENDP


		public _remove_from_lazy_defined_list
_remove_from_lazy_defined_list	PROC
		mov	ECX,8[ESP]
		mov	EAX,4[ESP]
_remove_from_lazy_defined_list	ENDP

REMOVE_FROM_LAZY_DEFINED_LIST	PROC

		PUSH	EDI
		MOV	EDI,OFF FIRST_LAZY_DEFINED_GINDEX
		JMP	RFEL_1

REMOVE_FROM_LAZY_DEFINED_LIST	ENDP


REMOVE_FROM_COMDAT_LIST	PROC

		PUSH	EDI
		MOV	EDI,OFF FIRST_COMDAT_GINDEX
		JMP	RFEL_1

REMOVE_FROM_COMDAT_LIST	ENDP


		public _remove_from_external_list
_remove_from_external_list	PROC
		mov	ECX,8[ESP]
		mov	EAX,4[ESP]
_remove_from_external_list	ENDP

REMOVE_FROM_EXTERNAL_LIST	PROC
		;
		;EAX IS GINDEX, ECX IS PHYSICAL
		;SAME IS TRUE ON EXIT
		;
		PUSH	EDI
		MOV	EDI,OFF FIRST_EXTERNAL_GINDEX
RFEL_1::
		ASSUME	ECX:PTR SYMBOL_STRUCT

		PUSHM	EBX,EAX

		XOR	EAX,EAX
		MOV	EBX,[ECX]._S_PREV_SYM_GINDEX

		MOV	[ECX]._S_PREV_SYM_GINDEX,EAX
		MOV	EDX,[ECX]._S_NEXT_SYM_GINDEX

		TEST	EBX,EBX
		JZ	PREV_NUL

		MOV	[ECX]._S_NEXT_SYM_GINDEX,EAX
		CONVERT	EAX,EBX,SYMBOL_GARRAY

		TEST	EDX,EDX

		MOV	[EAX].SYMBOL_STRUCT._S_NEXT_SYM_GINDEX,EDX
		JZ	NEXT_NUL
RFEL0:
		CONVERT	EDX,EDX,SYMBOL_GARRAY
		POP	EAX
		MOV	[EDX].SYMBOL_STRUCT._S_PREV_SYM_GINDEX,EBX

		POPM	EBX,EDI

		RET

PREV_NUL:
		MOV	[ECX]._S_NEXT_SYM_GINDEX,EAX
		MOV	[EDI],EDX		;FIRST

		TEST	EDX,EDX
		JNZ	RFEL0
NEXT_NUL:
		MOV	[EDI+4],EBX		;LAST
		POP	EAX

		POPM	EBX,EDI
		RET

REMOVE_FROM_EXTERNAL_LIST	ENDP


		public _remove_from__imp__list
_remove_from__imp__list	PROC
		mov	ECX,8[ESP]
		mov	EAX,4[ESP]
_remove_from__imp__list	ENDP

REMOVE_FROM__IMP__LIST	PROC

		PUSH	EDI
		MOV	EDI,OFF FIRST__IMP__GINDEX

		JMP	RFEL_1

REMOVE_FROM__IMP__LIST	ENDP

		public _remove_from_undecorated_list
_remove_from_undecorated_list	PROC
		mov	ECX,8[ESP]
		mov	EAX,4[ESP]
_remove_from_undecorated_list	ENDP

REMOVE_FROM_UNDECORATED_LIST	PROC

		PUSH	EDI
		MOV	EDI,OFF FIRST_UNDECORATED_GINDEX

		JMP	RFEL_1

REMOVE_FROM_UNDECORATED_LIST	ENDP


		public _remove_from_weak_list
_remove_from_weak_list	PROC
		mov	ECX,8[ESP]
		mov	EAX,4[ESP]
_remove_from_weak_list	ENDP

REMOVE_FROM_WEAK_LIST	PROC

		PUSH	EDI
		MOV	EDI,OFF FIRST_WEAK_GINDEX
		JMP	RFEL_1

REMOVE_FROM_WEAK_LIST	ENDP


REMOVE_FROM_WEAK_DEFINED_LIST	PROC

		PUSH	EDI
		MOV	EDI,OFF FIRST_WEAK_DEFINED_GINDEX

		JMP	RFEL_1

REMOVE_FROM_WEAK_DEFINED_LIST	ENDP


		public _remove_from_aliased_list
_remove_from_aliased_list	PROC
		mov	ECX,8[ESP]
		mov	EAX,4[ESP]
_remove_from_aliased_list	ENDP

REMOVE_FROM_ALIASED_LIST	PROC

		PUSH	EDI
		MOV	EDI,OFF FIRST_ALIASED_GINDEX

		JMP	RFEL_1

REMOVE_FROM_ALIASED_LIST	ENDP


REMOVE_FROM_LIBSYM_LIST	PROC
		;
		;EAX IS GINDEX, ECX IS PHYSICAL
		;SAME IS TRUE ON EXIT
		;
		PUSH	EDI
		MOV	EDI,[ECX]._S_LIB_GINDEX
		CONVERT	EDI,EDI,LIBRARY_GARRAY
		ASSUME	EDI:PTR LIBRARY_STRUCT

		PUSHM	EBX,EAX

		XOR	EAX,EAX
		MOV	EBX,[ECX]._S_PREV_SYM_GINDEX

		MOV	[ECX]._S_PREV_SYM_GINDEX,EAX
		MOV	EDX,[ECX]._S_NEXT_SYM_GINDEX

		TEST	EBX,EBX
		JZ	PREV_NUL

		MOV	[ECX]._S_NEXT_SYM_GINDEX,EAX
		CONVERT	EAX,EBX,SYMBOL_GARRAY

		TEST	EDX,EDX

		MOV	[EAX].SYMBOL_STRUCT._S_NEXT_SYM_GINDEX,EDX
		JZ	NEXT_NUL
RFEL0:
		CONVERT	EDX,EDX,SYMBOL_GARRAY
		POP	EAX
		MOV	[EDX].SYMBOL_STRUCT._S_PREV_SYM_GINDEX,EBX

		POPM	EBX,EDI

		RET

PREV_NUL:
		;
		;THERE IS NO PREVIOUS, MAKE FIRST POINT TO ME
		;
		MOV	[ECX]._S_NEXT_SYM_GINDEX,EAX
		TEST	EDX,EDX

		MOV	[EDI]._LS_FIRST_EXTRN_GINDEX,EDX
		JNZ	RFEL0
NEXT_NUL:
		;
		;THERE IS NO 'NEXT',MAKE LAST POINT TO MY PREV
		;
		POP	EAX
		MOV	[EDI]._LS_LAST_EXTRN_GINDEX,EBX

		POPM	EBX,EDI
		RET

REMOVE_FROM_LIBSYM_LIST	ENDP


		END

